{% extends "misago/admin/generic/list.html" %}
{% load i18n %}


{% block page-actions %}
<div class="col-auto page-action">
  <a href="{% url 'misago:admin:permissions:new' %}" class="btn btn-primary btn-sm">
    <span class="fa fa-plus-circle"></span>
    {% trans "New role" %}
  </a>
</div>
{% endblock %}


{% block table-header %}
<th>{% trans "Role" %}</th>
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td>
  <a href="{% url 'misago:admin:permissions:edit' pk=item.pk %}" class="item-name small">
    {{ item }}
  </a>
</td>
<td>
  <div class="dropdown">
    <button class="btn btn-light btn-sm dropdown-toggle" type="button" id="item-optioms-{{ item.pk }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      <i class="fas fa-ellipsis-h"></i>
    </button>
    <div class="dropdown-menu dropdown-menu-right" aria-labelledby="item-optioms-{{ item.pk }}">
      {% for action in extra_actions %}
        <a href="{% url action.link pk=item.pk %}" class="dropdown-item">
          {{ action.name }}
        </a>
      {% endfor %}
      <a class="dropdown-item" href="{% url 'misago:admin:permissions:users' pk=item.pk %}">
        {% trans "Users with role" %}
      </a>
      <a class="dropdown-item" href="{% url 'misago:admin:permissions:edit' pk=item.pk %}">
        {% trans "Edit role" %}
      </a>
      <form action="{% url 'misago:admin:permissions:delete' pk=item.pk %}" method="post" data-delete-confirmation="true">
        {% csrf_token %}
        <button class="dropdown-item">
          {% trans "Delete role" %}
        </button>
      </form>
    </div>
  </div>
</td>
{% endblock %}


{% block blankslate %}
<td colspan="2">
  {% trans "No user roles are set." %}
</td>
{% endblock blankslate %}


{% block javascripts %}
<script type="text/javascript">
  window.misago.initConfirmation(
    "[data-delete-confirmation]",
    "{% trans 'Are you sure you want to delete this role?' %}"
  )
</script>
{% endblock %}
